package com.bweab.controll.depositcontroll.en;

import com.bweab.pojo.DepositTb;
import com.bweab.service.api.DepositTbServiceInterface;
import com.bweab.service.api.en.DepositTbEnServiceInterface;
import com.bweab.service.impl.DepositTbServiceInterfaceImpl;
import com.bweab.service.impl.en.DepositTbEnServiceInterfaceImpl;
import com.bweab.util.JSONResult;
import com.bweab.util.PageList;
import com.bweab.util.WebUtil;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

@WebServlet("/queryDepositInfoByDormitoryId")
public class QueryDepositByDormitoryId extends HttpServlet {

    //创建服务对象
    DepositTbEnServiceInterface depositTbEnService =new DepositTbEnServiceInterfaceImpl();
    //创建返回结果
    JSONResult jsonResult =new JSONResult();
    //创建页面返回结果


    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //获取宿舍信息
        int dormitoryId = Integer.parseInt(req.getParameter("dormitoryId"));
        int page = Integer.parseInt(req.getParameter("page"));
        int pageSize = Integer.parseInt(req.getParameter("pageSize"));

        System.out.println("寝室id"+dormitoryId+"\n当前页面"+page+"页面大小");
        //调用宿舍服务
        PageList pageList = depositTbEnService.queryDepositInfoByDormitoryId(page,pageSize,dormitoryId);
//
        //返回数据
        WebUtil.writeJson(resp,pageList);


    }

}
